using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InventoryInFind : MonoBehaviour
{
    [SerializeField] RectTransform inFind;

    public void show(bool b)
    {
        inFind.gameObject.SetActive(b);
    }

    public void setSize(InventoryItem targetItem,ItemGrid itemGrid)
    {
        Vector2 size = new Vector2();
        size.x = targetItem.WIDTH * itemGrid.tileSizeWidth;
        size.y = targetItem.HEIGHT * itemGrid.tileSizeHeight;
        inFind.sizeDelta = size;
    }

    public void setParent(ItemGrid targetGrid)
    {
        if (targetGrid == null) { return; }
        inFind.SetParent(targetGrid.GetComponent<RectTransform>());
    }
    public void SetPosition(ItemGrid targetGrid, InventoryItem targetItem)
    {
        Vector2 pos = targetGrid.calculatePositionOnGrid(targetItem, targetItem.onGridPositionX, targetItem.onGridPositionY);
        inFind.localPosition = pos;
    }

    public void SetPosition(ItemGrid targetGrid, InventoryItem targetItem, int posX, int posY)
    {
        Vector2 pos = targetGrid.calculatePositionOnGrid(targetItem, posX, posY);
        inFind.localPosition = pos;
    }
}
